package com.qisu.cacheMap;

import java.util.concurrent.ConcurrentHashMap;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import com.qisu.model.vo.DivisionPrice;

import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;


/**
 * 分时电价与时间缓存
 * @author li
 *
 */
@Component
@Configuration
public class TimeAndPriceCache {
	private Log log = LogFactory.get();
	private ConcurrentHashMap<String,  DivisionPrice> divisionPrice = new ConcurrentHashMap<>();

	@Value("${logging.feature.channelList:false}") private boolean enable;
	
	public TimeAndPriceCache put(String key, DivisionPrice value) {
		divisionPrice.put(key, value);
		return this;
	}

	
	public DivisionPrice get(String key) {
		if(divisionPrice.containsKey(key)) {
			return divisionPrice.get(key);
		}
		return null;
	}

	public void remove(String key) {
		if(divisionPrice.containsKey(key)) {
			divisionPrice.remove(key);
			log.debug(key + " removed from ELECTRICITYCACHE");
		}
	}


	/*public int size() {
		return electricityCache.size();
	}*/
}
